# 响应码定义
HTTP_STATUS = {
    # 成功响应
    200: 'OK',
    201: 'Created',
    204: 'No Content',

    # 客户端错误
    400: 'Bad Request',
    401: 'Unauthorized',
    403: 'Forbidden',
    404: 'Not Found',
    405: 'Method Not Allowed',
    422: 'Unprocessable Entity',

    # 服务器错误
    500: 'Internal Server Error',
    502: 'Bad Gateway',
    503: 'Service Unavailable'
}

# 自定义业务响应码
BUSINESS_CODE = {
    # 成功
    0: 'Success',

    # 通用错误
    10001: 'System Error',
    10002: 'Parameter Error',
    10003: 'Database Error',
    10004: 'Resource Not Found',

    # 认证授权错误
    20001: 'Authentication Failed',
    20002: 'Authorization Failed',

    # 业务特定错误
    # 可以根据具体业务需求添加
}

# 响应结构类
class APIResponse:
    @staticmethod
    def success(data=None, message='Success', code=200):
        return {
            'code': code,
            'message': message,
            'data': data
        }, 200

    @staticmethod
    def fail(message='Failed', code=10001, status_code=200):
        return {
            'code': code,
            'message': message,
            'data': None
        }, status_code

    @staticmethod
    def validate_error(message='Validation Error', code=100):
        return {
            'code': code,
            'message': message,
            'data': None
        }, 400

    @staticmethod
    def not_found(message='Resource Not Found', code=200):
        return {
            'code': code,
            'message': message,
            'data': None
        }, 404